package com.ruoyi.web.controller.deal;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.deal.deal_service.domain.DealService;
import com.ruoyi.deal.deal_service.domain.InfoToDealService;
import com.ruoyi.deal.deal_service.service.IDealServiceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交易服务信息Controller
 *
 * @author zhezhi
 * @date 2022-10-06
 */
@RestController
@RequestMapping("/deal/serviceInfo")
public class DealServiceController extends BaseController
{
    @Autowired
    private IDealServiceService dealServiceService;

    /**
     * 查询交易服务信息列表
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:list')")
    @GetMapping("/list")
    @ApiOperation("查询交易服务信息列表")
    public TableDataInfo list(InfoToDealService InfoToDealService)
    {
        startPage();
        List<InfoToDealService> list = dealServiceService.selectDealServiceList(InfoToDealService);
        return getDataTable(list);
    }

    /**
     * 导出交易服务信息列表
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:export')")
    @Log(title = "交易服务信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出交易服务信息列表")
    public void export(HttpServletResponse response, InfoToDealService InfoToDealService)
    {
        List<InfoToDealService> list = dealServiceService.selectDealServiceList(InfoToDealService);
        ExcelUtil<InfoToDealService> util = new ExcelUtil<InfoToDealService>(InfoToDealService.class);
        util.exportExcel(response, list, "交易服务信息数据");
    }

    /**
     * 获取交易服务信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:query')")
    @GetMapping(value = "/{serviceId}")
    @ApiOperation("获取交易服务信息详细信息")
    public AjaxResult getInfo(@PathVariable("serviceId") Long serviceId)
    {
        return AjaxResult.success(dealServiceService.selectDealServiceByServiceId(serviceId));
    }

    /**
     * 新增交易服务信息
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:add')")
    @Log(title = "交易服务信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增交易服务信息")
    public AjaxResult add(@RequestBody InfoToDealService InfoToDealService)
    {
        return toAjax(dealServiceService.insertDealService(InfoToDealService));
    }

    /**
     * 修改交易服务信息
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:edit')")
    @Log(title = "交易服务信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改交易服务信息")
    public AjaxResult edit(@RequestBody InfoToDealService InfoToDealService)
    {
        return toAjax(dealServiceService.updateDealService(InfoToDealService));
    }

    /**
     * 删除交易服务信息
     */
    @PreAuthorize("@ss.hasPermi('deal:serviceInfo:remove')")
    @Log(title = "交易服务信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceIds}")
    @ApiOperation("删除交易服务信息")
    public AjaxResult remove(@PathVariable Long[] serviceIds)
    {
        return toAjax(dealServiceService.deleteDealServiceByServiceIds(serviceIds));
    }
}
